<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JQuery获取DOM</title>
</head>
<body>
<select name="province" lay-filter="province" class="province"></select>


<script src="js/jquery-3.2.1.min.js"></script>
<script>
    $("select[name=province]").append("<option>'测试'</option>");
    /*根据select name获取dom*/

    var data = [
                {
                    code: "31",
                    name: "运动",
                    childs: [
                        {
                            code: "3101",
                            name: "球类",
                            childs: [
                                {
                                    code: "310151",
                                    name: "篮球"
                                },
                                {
                                    code: "310151",
                                    name: "羽毛球"
                                }
                            ]
                        },
                        {
                            code: "3101",
                            name: "田径",
                            childs: [
                                {
                                    code: "310151",
                                    name: "400米接力"
                                },
                                {
                                    code: "310151",
                                    name: "跳远"
                                }
                            ]
                        }
                    ]
                },
                {
                    code: "32",
                    name: "学习",
                    childs: [
                        {
                            code: "3101",
                            name: "线上",
                            childs: [
                                {
                                    code: "310151",
                                    name: "线上英语"
                                },
                                {
                                    code: "310151",
                                    name: "线上数学"
                                }
                            ]
                        },
                        {
                            code: "3101",
                            name: "线下",
                            childs: [
                                {
                                    code: "310151",
                                    name: "纸质书学习"
                                },
                                {
                                    code: "310151",
                                    name: "家教"
                                }
                            ]
                        }
                    ]
                }
            ];
//    console.log(data[$(this).index() - 1].childs);
    console.log(data[$(this).index()]);
//    console.log(data[0].childs);
</script>
</body>
</html>